﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverChart.Core.Configuration;
using SilverChart.Core.Service;
using System.Collections.Generic;

namespace SilverChart.UnitTest.Configuration {
    [ServiceProvider]
    public class MockedConfigurationParserFactory : ConfigurationParserFactory{
        public const String MOCKED_CONFIGURATIONS_STRING = "Mocked_Configurations_String";

        public ConfigurationParser CreateParser(string ConfigString, string RootItemName) {
            MockedConfigurationParser parser = new MockedConfigurationParser();
            IList<Type> rootTypes = ServiceManager.Instance.GetService<ConfigurationService>().GetRootConfiguratioItems(RootItemName);
            if (rootTypes.Count == 0) {
                return null;
            }
            Type rootType = rootTypes[0];

            ConfigurationItem configItem = AbstractConfigurationItem.CreateInstance(rootType, parser);
            parser.Configuration = configItem;

            return parser;
        }

        public bool IsCompatible(string ConfigString) {
            if (ConfigString == MOCKED_CONFIGURATIONS_STRING) {
                return true;
            }
            return false;
        }
    }
}
